package com.gitee.wsl.unit.angle.ext

import com.gitee.wsl.unit.angle.AngleUnit
import com.gitee.wsl.unit.angle.AngleUnit.Companion.STRECK_TO_DEGREES
import com.gitee.wsl.unit.angle.AngleUnit.Degrees
import kotlin.jvm.JvmStatic


/**
 * Convert degrees to minutes
 *
 * @param degrees value in degrees
 *
 * @return value in minutes
 */
fun AngleUnit.Companion.toMinutes(degrees: Double) = degrees * DEGREES_TO_MINUTES

/**
 * Convert degrees to seconds
 *
 * @param degrees value in degrees
 *
 * @return value in seconds
 */
fun AngleUnit.Companion.toSeconds(degrees: Double) = degrees * DEGREES_TO_SECONDS

/**
 * Convert degrees to milliradians
 *
 * @param degrees value in degrees
 *
 * @return value in milliradians
 */
fun AngleUnit.Companion.toMrad(degrees: Double) = degrees * DEGREES_TO_MRAD

/**
 * Convert degrees to mil NATO
 *
 * @param degrees value in degrees
 *
 * @return value in mil NATO
 */
fun AngleUnit.Companion.toMilNATO(degrees: Double) = degrees * DEGREES_TO_MIL_NATO

/**
 * Convert degrees to mil Warsaw Pact
 *
 * @param degrees value in degrees
 *
 * @return value in mil Warsaw Pact
 */
fun AngleUnit.Companion.toMilWP(degrees: Double) = degrees * DEGREES_TO_MIL_WP

/**
 * Convert degrees to Streck
 *
 * @param degrees value in degrees
 *
 * @return value in mil Streck
 */
fun AngleUnit.Companion.toStreck(degrees: Double) = degrees * DEGREES_TO_STRECK

/**
 * Convert degrees to minute of angle (MOA)
 *
 * @param degrees value in degrees
 *
 * @return value in minute of angle (MOA)
 */
fun AngleUnit.Companion.toMOA(degrees: Double) = degrees * DEGREES_TO_MOA

/**
 * Obtains an angle from a specified number of minutes.
 *
 * @param minutes the size in minutes of the angle to be obtained.
 *
 * @return a new angle, whose size in minutes is given by [minutes].
 */
fun AngleUnit.Companion.fromMinutes(minutes: Double) = Degrees(minutes * MINUTES_TO_DEGREES)

/**
 * Obtains an angle from a specified number of seconds.
 *
 * @param seconds the size in seconds of the angle to be obtained.
 *
 * @return a new angle, whose size in seconds is given by [seconds].
 */
fun AngleUnit.Companion.fromSeconds(seconds: Double) = Degrees(seconds * SECONDS_TO_DEGREES)

/**
 * Obtains an angle from a specified number of milliradians.
 *
 * @param mrad the size in milliradians of the angle to be obtained.
 *
 * @return a new angle, whose size in milliradians is given by [mrad].
 */
fun AngleUnit.Companion.fromMrad(mrad: Double) = Degrees(mrad * MRAD_TO_DEGREES)

/**
 * Obtains an angle from a specified number of mil NATO.
 *
 * @param milNATO the size in mil NATO of the angle to be obtained.
 *
 * @return a new angle, whose size in mil NATO is given by [milNATO].
 */
fun AngleUnit.Companion.fromMilNATO(milNATO: Double) = Degrees(milNATO * MIL_NATO_TO_DEGREES)

/**
 * Obtains an angle from a specified number of mil Warsaw Pact.
 *
 * @param milWP the size in mil WP of the angle to be obtained.
 *
 * @return a new angle, whose size in mil WP is given by [milWP].
 */
fun AngleUnit.Companion.fromMilWP(milWP: Double) = Degrees(milWP * MIL_WP_TO_DEGREES)

/**
 * Obtains an angle from a specified number of minute of angle (MOA).
 *
 * @param moa the size in MOA of the angle to be obtained.
 *
 * @return a new angle, whose size in MOA is given by [moa].
 */
fun AngleUnit.Companion.fromMOA(moa: Double) = Degrees(moa * MOA_TO_DEGREES)

/**
 * Obtains an angle from a specified number of Streck.
 *
 * @param streck the size in Streck of the angle to be obtained.
 *
 * @return a new angle, whose size in Streck is given by [streck].
 */
fun AngleUnit.Companion.fromStreck(streck: Double) = Degrees(streck * STRECK_TO_DEGREES)